﻿@model List<ByHand.Model.City>
@{
    ViewBag.Title = "City";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@if (TempData["mess"] != null)
{ 
    <div class="alert alert-success">@TempData["mess"]</div>
}
@using (Html.BeginForm("SaveCity", "Home", FormMethod.Post))
{
    <div class="input-group">
        <span class="input-group-addon">City Name</span>
        <input type="text" name="name" class="form-control" placeholder="City Name">
        <span class="input-group-btn">
            <button class="btn btn-primary" type="submit">Add City</button>
        </span>
    </div>
}
@using (Html.BeginForm("SaveDistrict", "Home", FormMethod.Post, new { Class = "form-inline" }))
{
  <input type="text" class="form-control" name="name" placeholder="District Name">
  <select name="cityID">
      @foreach (var item in Model)
	{
		 <option value="@item.ID">@item.Name</option>
	}
  </select>
  <button type="submit" class="btn btn-default">Add District</button>
}
<ul>
    @foreach (var c in Model.OrderBy(c => c.Name))
    {
        <li>@c.Name
            <ul>
                @foreach (var item in c.Districts.OrderBy(d=>d.Name))
                {
                    <li>@item.Name</li>
                }
            </ul>
        </li>
    }
</ul>
